package algorithm.poj.p1000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;

/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 分类：数学
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P1061 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P1061.class.getResource("P1061.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		StringTokenizer st = new StringTokenizer(line);
		long x = Long.valueOf(st.nextToken());
		long y = Long.valueOf(st.nextToken());
		long m = Long.valueOf(st.nextToken());
		long n = Long.valueOf(st.nextToken());
		long L = Long.valueOf(st.nextToken());
		long a = m-n;
		long b = L;
		long c = y-x;
		//求解方程 a*t + b*s = c 满足 t>=0 的最小解(t, s)
		long[] r = solve(a, b);
		long d = a*r[0] + b*r[1];
		if (c%d == 0) {
			long c1 = c/d;
			long b1 = b/d;
			long t = r[0]*c1;
			while (t < 0) t += b1;
			System.out.println(t%b1);
		} else {
			System.out.println("Impossible");
		}
	}
	
	/**
	 * return (t, s) satisfy equation: a*t + b*s = gcd(a,b)
	 * @param a
	 * @param b
	 * @return
	 */
	private static long[] solve(long a, long b) {
		
		if (a < 0) {
			a = -a;
			long[] r = solve(a, b);
			return new long[] {-r[0], r[1]};
		}
		if (b < 0) {
			b = -b;
			long[] r = solve(a, b);
			return new long[] {r[0], -r[1]};
		}
		if (a == 0) {
			return new long[] {0, 1};
		} else if (b == 0) {
			return new long[] {1, 1};
		} else {
			if (a < b) {
				long[] r = solve(b, a);
				return new long[] {r[1], r[0]};
			} else {
				long[] r = solve(b, a%b);
				long m = a/b;
				return new long[] {r[1], r[0]-r[1]*m};
			}
		}
	}
}
